<include file="public:header" />
<include file="public:left" />

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>订单列表</h3>
                <h5>(共{$count}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline"  method="get" action=""  name="search-form2" id="search-form2">
                <input type="hidden" name="order_by" value="order_id">
                <input type="hidden" name="sort" value="desc">
                <div class="sDiv">
                    <div class="sDiv2">
                        <select name="status" class="select" style="width:100px;margin-right:5px;margin-left:5px">
                            <option value=""  >订单状态</option>
                            <option value="0" <eq name="status"	value="0">selected</eq>>待接单</option>
                            <option value="1" <eq name="status"	value="1">selected</eq>>已接单</option>
                            <option value="-1" <eq name="status"	value="2">selected</eq>>不接单</option>
                            <option value="2" <eq name="status"	value="3">selected</eq>>已完成</option>
                        </select>
                    </div>
                    <div class="sDiv2">
                        <input type="submit"   class="btn" value="搜索">
                        <!--	<input type="submit" name="export"   class="btn" value="导出">-->
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox" id="ajax_return">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th class="sign" axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" abbr="order_sn" axis="col3" class="">
                            <div style="text-align: left; width: 140px;" class="">订单编号</div>
                        </th>
                        <th align="left" abbr="consignee" axis="col4" class="">
                            <div style="text-align: left; width: 150px;" class="">接单司机资料</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">配送开始时间</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">完成时间</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">订单状态</div>
                        </th>
                        <th align="left" axis="col1" class="handle">
                            <div style="text-align: left; width: 150px;">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>

        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table>
                    <tbody>
                    <if condition="empty($list) eq true">
                        <tr data-id="0">
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                        <else/>
                        <volist name="list" id="list">
                            <tr data-order-id="{$list.id}">
                                <td class="sign" axis="col0" style="text-align: left; width: 20px;" >
                                    <div style="width: 24px;"><i class="ico-check"></i></div>
                                </td>
                                <td align="left" abbr="order_sn" axis="col3" class="" style="text-align: left; width: 130px;" >
                                    <div style="text-align: left; width: 130px;" class="">{$list.driver_order_sn}</div>
                                </td>
                                <td align="left" abbr="consignee" axis="col4" class="" style="text-align: left; width: 150px;" >
                                    <div style="text-align: left; width: 150px;" class=""><if condition="!empty($list.driver_id)">{$list.driver_info.nickname} {$list.driver_info.mobile}</if></div>
                                </td>
                                <td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 120px;">
                                    <div style="text-align: center; width: 120px;" class=""><gt name="list.send_time" value="0">{$list.send_time|date='Y-m-d H:i',###}</gt></div>
                                </td>
                                <td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width:120px;">
                                    <div style="text-align: center; width: 120px;" class=""><gt name="list.finish_time" value="0">{$list.finish_time|date='Y-m-d H:i',###}</gt></div>
                                </td>
                                <td align="center" abbr="article_show" axis="col5" class="" style="text-align: center; width: 60px;">
                                    <div style="text-align: center; width: 60px;" class="">
                                        <switch name="list.status">
                                            <case value="0">待接单</case>
                                            <case value="1">已接单</case>
                                            <case value="-1">不接单</case>
                                            <case value="2">已完成</case>
                                        </switch>
                                    </div>
                                </td>
                                <td align="left" axis="col1" class="handle" align="center">
                                    <div style="text-align: left; ">
                                        <a class="btn green" href="{:url('order/driver_order_detail',array('id'=>$list['id']))}"><i class="fa fa-list-alt"></i>查看</a>
                                        <a data-url="{:url('order/getBestroute')}" data-id="{$list['id']}" onclick="dealfun(this)" class="btn blue"><i class="fa fa-pencil-square-o"></i>生成路线</a>
                                        <lt name="$list['status']" value="1">
                                            <a href="{:url('order/driver_order_setdriver',array('id'=>$list['id']))}" data-id="{$list['id']}"  class="btn blue"><i class="fa fa-pencil-square-o"></i>重选配送司机</a>
                                        </lt>
                                    </div>
                                </td>
                            </tr>
                        </volist>
                    </if>
                    </tbody>
                </table>
                <div class="row">
                    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right"></div>
                </div>
                <script>
                    $(".pagination  a").click(function(){
                        var page = $(this).data('p');
                        ajax_get_table('search-form2',page);
                    });

                    $('.ftitle>h5').empty().html("(共{$count}条记录)");
                </script>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
        {$page}
    </div>
</div>
<script type="text/javascript" src="__STATIC__/admin/js/laydate/laydate.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        laydate({
            elem: '#add_time_begin', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            format: 'YYYY-MM-DD hh:mm:ss',//YYYY/MM/DD hh:mm:ss
            istime: true,
            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
        });
        laydate({
            elem: '#add_time_end', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            format: 'YYYY-MM-DD hh:mm:ss',//YYYY/MM/DD hh:mm:ss
            istime: true,
            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
        });
        // 点击刷新数据
        $('.pReload').click(function(){
            window.location.reload()
        });
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });
        $('.hDivBox .ico-check').click(function(){
            $('tr').toggleClass('trSelected' , function(index,currentclass){
                var hasClass = $(this).hasClass('trSelected');
                $('tr' , '#flexigrid').each(function(){
                    if(hasClass){
                        $(this).addClass('trSelected');
                    }else{
                        $(this).removeClass('trSelected');
                    }
                });
            });
        });
    });
    // 点击排序
    function sort(field){
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
    function dealfun(obj) {
        $.ajax({
            type: 'post',
            url: $(obj).attr('data-url'),
            data: {id: $(obj).attr('data-id')},
            dataType: 'json',
            success: function (result) {
//                console.log(result);
                if (result.code == 0) {
                    layer.alert(result.msg, {icon: 2});  //alert('失败');
                } else {
                    layer.alert(result.msg, {icon: 1});
                }
            }
        })
    }
    function exportReport(){
        var selected_ids = '';
        $('.trSelected' , '#flexigrid').each(function(i){
            selected_ids += $(this).data('order-id')+',';
        });
        if(selected_ids != ''){
            $('input[name="order_ids"]').val(selected_ids.substring(0,selected_ids.length-1));
        }
        $('#search-form2').submit();
    }


</script>
</body>
</html>